package aryn.framework.display.drawable;

import java.awt.Graphics;
import java.awt.Image;

import aryn.framework.display.MyCanvas;
import aryn.framework.graphic.Load;
import aryn.framework.utilities.Util;

public class DrawingImage extends Drawable {
	private Image image;
	
	public DrawingImage(Image image, int x, int y, Priority priority, MyCanvas canvas) {
		super(x, y, priority, canvas);
		this.image = image;
	}
	
	public DrawingImage(String imagePath, int x, int y, MyCanvas canvas) {
		this(Load.bufferedImage(imagePath), x, y, Priority.MIDDLE, canvas);
	}

	@Override
	public void draw(Graphics g) {
		if (x + image.getWidth(canvas) >= 0 && y + image.getHeight(canvas) >= 0 &&
				x <= canvas.getWidth() && y <= canvas.getHeight() )
			g.drawImage(image, x, y, canvas);
	}
	
	@Override
	public boolean isMouseOver(int mouseX, int mouseY) {
		return Util.mouseBound(mouseX, mouseY, this.x, this.y,
				this.x + image.getWidth(canvas), this.y + image.getHeight(canvas));
	}
	
	public Image getImage() {
		return image;
	}
	public void setImage(Image image) {
		this.image = image;
	}
	
}
